property kasSysDepth : {0, 4 + 32, 1, 8, 4 + 32, 1} -- + 32 for greyscale, 0 for deepest current monitor
property kasTitle : "Startup Progress Picture"
global gasStat
on run
set gasStat to 0
if (WeHavePreserves()) then
set choice to ShowChoice("Do you wish to view the current Startup Progress Pictures, copy the original to the clipboard, or restore their original state?", ¬
{"Copy", "Restore", "View"})
if choice is "View" then
ShowEm()
else if choice is "Copy" then
CopyMain(true)
else
RestorePreserve()
end if
else
ShowStatus(1, "Drop an image file on this script to have it replace your MacOS Startup Progress Picture.")
set choice to ShowChoice("Do you wish to view the current Startup Progress Pictures or copy the current picture to the clipboard?", ¬
{"Cancel", "Copy", "View"})
if (choice is "View") then
ShowEm()
else if choice is "Copy" then
CopyMain(false)
end if
end if
CloseStatus()
end run
on open fsObjs
set gasStat to 0
if (the number of items of fsObjs is not 1) then
ShowAlert("You can only drop one picture on this script." & return & return & ¬
"Dropping more than one is only a waste of time...")
else
-- Save current for later restoration
if not WeHavePreserves() then ¬
PreserveCurrent()
InstallEm(item 1 of fsObjs)
end if
CloseStatus()
end open
on InstallEm(fsObj)
set fname to catalog name of (basic info for fsObj)
ShowStatus(2, "Loading " & fname)
set n to the number of items of kasSysPicts
set pic to the image from fsObj
ShowStatus(2, "Installing " & fname)
set havePres to WeHavePreserves()
repeat with i from 1 to n
ShowStatus(3, "Drawing " & i & " of " & n)
set rn to item i of kasSysPicts
set newDepth to item i of kasSysDepth
-- Get deepest?
if (newDepth is 0) then set newDepth to GetDeepestDepth()
set win to ShowOne(rn, havePres)
pause for 44 -- Allow window to update itself
set wBox to {0, 0} & (window dimensions of win)
-- Replace old picture with new one in window
draw a picture ¬
into win ¬
inside of wBox ¬
using data pic ¬
with a clear slate
ShowStatus(3, "Capturing " & i & " of " & n)
-- Capture it
set newPic to ¬
capture picture from win ¬
using depth newDepth ¬
with pixel conversion and dithering
ShowStatus(3, "Showing " & i & " of " & n)
draw a picture ¬
into win ¬
inside of wBox ¬
using data newPic ¬
with a clear slate without recording
ShowStatus(3, "Saving " & i & " of " & n)
save resource newPic ¬
named ("Akua") ¬
numbered rn
ShowStatus(3, "Done " & i & " of " & n)
CloseShow(win)
end repeat
end InstallEm
on CopyMain(fromPreserve)
if (fromPreserve) then
clip RestoreGet(item 1 of kasSysPicts)
PasteInScrapBook()
end if
set win to ShowOne(item 1 of kasSysPicts, false)
clip (capture picture from win)
CloseShow(win)
PasteInScrapBook()
end CopyMain
on PasteInScrapBook()
tell application "Scrapbook"
activate
input state {keys down:"V", command key down:true} -- paste it
end tell
activate
end PasteInScrapBook
on ShowEm()
repeat with rn in kasSysPicts
set win to ShowOne(rn, false)
pause for 3 with seconds timing
CloseShow(win)
end repeat
end ShowEm
on ShowOne(rn, fromPreserves)
if (fromPreserves) then
set spic to RestoreGet(rn)
else
set spic to the resource of type ¬
"PICT" numbered rn
end if
return ¬
display drawing titled ("System Picture " & rn) ¬
starting with spic
end ShowOne
on CloseShow(win)
display drawing win ¬
with disposal
end CloseShow
on PreserveCurrent()
repeat with rn in kasSysPicts
ShowStatus(4, "Preserving " & rn)
PreserveOne(rn)
end repeat
ShowStatus(4, "…")
end PreserveCurrent
on RestorePreserve()
repeat with rn in kasSysPicts
ShowStatus(4, "Restoring " & rn)
RestoreOne(rn)
end repeat
ShowStatus(4, "…")
end RestorePreserve
property kpfNameOne : "System Picture "
property kpfName : "Startup Progress Preserve"
on PreserveOne(rn)
set spic to the resource of type ¬
"PICT" numbered rn
save preference spic ¬
named (kpfNameOne & rn) ¬
in file named kpfName
end PreserveOne
on RestoreOne(rn)
try
set spic to RestoreGet(rn)
on error
ShowAbort("There is apparently no preserve to restore!")
end try
save resource spic ¬
numbered rn
end RestoreOne
on RestoreGet(rn)
return load preference named (kpfNameOne & rn) ¬
in file named kpfName
end RestoreGet
on WeHavePreserves()
set rn to the last item of kasSysPicts
try
load preference named (kpfNameOne & rn) ¬
in file named kpfName
on error
return false
end try
return true
end WeHavePreserves
on ShowAbort(msg)
return ShowChoice(msg, {"Cancel"})
end ShowAbort
on ShowAlert(msg)
return ShowChoice(msg, {"OK"})
end ShowAlert
on ShowChoice(msg, btns)
return button returned of ¬
(display dialog msg ¬
buttons btns ¬
default button (number of items of btns))
end ShowChoice
on ShowStatus(n, msg)
if (gasStat is 0) then
set gasStat to ¬
display info titled kasTitle ¬
message "…" located at {20, 48}
display info gasStat message "…" at line 2
display info gasStat message "…" at line 3
display info gasStat message "…" at line 4
end if
display info gasStat ¬
message msg ¬
at line n
end ShowStatus
on CloseStatus()
if (gasStat is not 0) then
display info gasStat with disposal
set gasStat to 0
end if
end CloseStatus
on GetDeepestDepth()
set disps to the display information
set deepest to 0
repeat with disp in disps
set thisDepth to the monitor depth of disp
if (thisDepth > deepest) then set deepest to thisDepth